﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace GroupChallengeWP7.Views
{
    public partial class QuestionView : UserControl
    {
        // Hold last number that was attempted on new question.
        private int _LastQuesionAnswered = 0;

        public QuestionView()
        {
            InitializeComponent();
        }

        private void AnswerButtonClick(object sender, RoutedEventArgs e)
        {
            MainViewModel viewModel = App.ViewModel;
            Button button = sender as Button;

            if (null != viewModel &&
                null != button)
            {
                string answerNumberText = button.Content as string;
                int answerNumber = 0;
                Int32.TryParse(answerNumberText, out answerNumber);

                _LastQuesionAnswered = viewModel.Answer(answerNumber, _LastQuesionAnswered);
            }
        }
    }
}
